import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
 *Es la clase donde se crea el escenario del juego.
 * 
 * @author (Cesar y Octavio) 
 * @version (2014.11.28) 
 */
public class Menu extends World
{
    private boolean musica=true;
    private GreenfootSound musicMenu;
    /**
     * Constructor for objects of class Menu.
     * 
     */
    
    public Menu()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
       super(600, 400, 1,false); 
       setBackground(new GreenfootImage("106826.jpg"));
        musicMenu=new GreenfootSound("music_game.wav");
        //musicMenu.playLoop();

        prepare();
    }
   /**
    * metodo donde se ejecuta el sonido del menu
    */
    public void act()
    {
        if(musica)
        musicMenu.play();
        
    }

    /**
     * metodo donde se crean los diferentes tipos de botones y letras del escenario
     */
    private void prepare()
    {
        Button b1 = new Play();
        addObject(b1,getWidth()/2-100, getHeight()/2+20); 
        Button b2 = new Help();
        addObject(b2,getWidth()/2-50, getHeight()/2+70);
        Button b3 = new Credits();
        addObject(b3,getWidth()/2, getHeight()/2+120);
        Button b4 = new Records();
        addObject(b4,getWidth()/2+50, getHeight()/2+170);
        
        
        Message m1=new Message(3);
        addObject(m1,50,50); 
        m1.appearsMessage();
         
        Message m2=new Message(4);
        addObject(m2,110,50); 
        m2.appearsMessage();
        
        Message m3=new Message(5);
        addObject(m3,170,50); 
        m3.appearsMessage();
        
        Message m4=new Message(6);
        addObject(m4,240,50); 
        m4.appearsMessage();
        
        Message m5=new Message(7);
        addObject(m5,300,50); 
        m5.appearsMessage();
        
        Message m6=new Message(3);
        addObject(m6,150,150);
        m6.appearsMessage();
        
        Message m7=new Message(8);
        addObject(m7,220,150);
        m7.appearsMessage();
        
        Message m8=new Message(11);
        addObject(m8,300,150);
        m8.appearsMessage();
        
        Message m9=new Message(11);
        addObject(m9,380,150);
        m9.appearsMessage();
        
        Message m10=new Message(10);
        addObject(m10,450,150);
        m10.appearsMessage();
        
         Message m11=new Message(7);
        addObject(m11,500,150);
        m11.appearsMessage();
        
        Message m12=new Message(9);
        addObject(m12,550,150);
        m12.appearsMessage();
       
    }
    
    /**
     * metodo para regresar al estado original del mundo.
     */
    public void restaura()
    {
        //List<Button> buttons=getObjects
        removeObjects(getObjects(Button.class));
        removeObjects(getObjects(Message.class));
        removeObjects(getObjects(ScoreBoard.class));
        Button b1 = new Play();
        addObject(b1,getWidth()/2-100, getHeight()/2+20); 
        Button b2 = new Help();
        addObject(b2,getWidth()/2-50, getHeight()/2+70);
        Button b3 = new Credits();
        addObject(b3,getWidth()/2, getHeight()/2+120);
        Button b4 = new Records();
        addObject(b4,getWidth()/2+50, getHeight()/2+170);
        
        
        Message m1=new Message(3);
        addObject(m1,50,50); 
        m1.appearsMessage();
         
        Message m2=new Message(4);
        addObject(m2,110,50); 
        m2.appearsMessage();
        
        Message m3=new Message(5);
        addObject(m3,170,50); 
        m3.appearsMessage();
        
        Message m4=new Message(6);
        addObject(m4,240,50); 
        m4.appearsMessage();
        
        Message m5=new Message(7);
        addObject(m5,300,50); 
        m5.appearsMessage();
        
        Message m6=new Message(3);
        addObject(m6,150,150);
        m6.appearsMessage();
        
        Message m7=new Message(8);
        addObject(m7,220,150);
        m7.appearsMessage();
        
        Message m8=new Message(11);
        addObject(m8,300,150);
        m8.appearsMessage();
        
        Message m9=new Message(11);
        addObject(m9,380,150);
        m9.appearsMessage();
        
        Message m10=new Message(10);
        addObject(m10,450,150);
        m10.appearsMessage();
        
         Message m11=new Message(7);
        addObject(m11,500,150);
        m11.appearsMessage();
        
        Message m12=new Message(9);
        addObject(m12,550,150);
        m12.appearsMessage();
        
        setBackground(new GreenfootImage("106826.jpg"));
    }
    /**
     * metodo para empezar la musica
     */
     public void started()
    {
       super.started();
       musicMenu.setVolume(80);
       //musicMenu.playLoop();
    }
    /**
     * metodo para detener la musica
     */
    public void stopped()
    { 
      super.stopped();
      musicMenu.pause();
      musica=false;
      
   }
}
